package economy;

import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;

import main.QConomy;

public class EconomyListener implements Listener {
	private final EconomyLoader economyLoader;
	
	public EconomyListener(QConomy plugin) {
		Bukkit.getPluginManager().registerEvents(this, plugin);
		economyLoader = new EconomyLoader(plugin);
	}
	
	public void quit() {
		economyLoader.quit();
	}
	
	@EventHandler
	private void playerLogin(PlayerJoinEvent event) {
		economyLoader.loadPlayer(event.getPlayer());
	}
	
	@EventHandler
	private void playerQuit(PlayerQuitEvent event) {
		economyLoader.savePlayer(event.getPlayer());
	}
}
